﻿package mortal.game.scene3D.fight.dramaEffect.rule
{
    import baseEngine.core.*;
    import com.gengine.utils.pools.*;
    import com.greensock.*;
    import mortal.game.scene3D.fight.dramaEffect.data.*;
    import mortal.game.scene3D.player.entity.*;

    public class DramaTweenRule extends Object
    {
        protected var _effectPlayer:Pivot3D;
        protected var _dramaMoveData:DramaMoveData;
        protected var _endCallBack:Function;

        public function DramaTweenRule()
        {
            return;
        }// end function

        public function play(param1:Pivot3D, param2:DramaMoveData, param3:Function = null) : void
        {
            var $effectPlayer:* = param1;
            var $dramaMoveData:* = param2;
            var endCallBack:* = param3;
            this._endCallBack = endCallBack;
            this._effectPlayer = $effectPlayer;
            this._dramaMoveData = $dramaMoveData;
            (this._effectPlayer as IGame2D).x2d = this._dramaMoveData.startX;
            (this._effectPlayer as IGame2D).y2d = this._dramaMoveData.startY;
            this._effectPlayer.scaleX = this._dramaMoveData.startScale;
            this._effectPlayer.scaleY = this._dramaMoveData.startScale;
            this._effectPlayer.scaleZ = this._dramaMoveData.startScale;
            TweenLite.to(this._effectPlayer, this._dramaMoveData.moveTime / 1000, {x2d:this._dramaMoveData.endX, y2d:this._dramaMoveData.endY, scaleX:this._dramaMoveData.endScale, scaleY:this._dramaMoveData.endScale, scaleZ:this._dramaMoveData.endScale, onComplete:function () : void
            {
                playEnd();
                return;
            }// end function
            });
            return;
        }// end function

        protected function playEnd() : void
        {
            if (this._endCallBack != null)
            {
                this._endCallBack.call();
            }
            this.dispose();
            return;
        }// end function

        public function dispose() : void
        {
            this._effectPlayer = null;
            this._dramaMoveData = null;
            this._endCallBack = null;
            ObjectPool.disposeObject(this);
            return;
        }// end function

    }
}
